﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Model;
using System.Drawing;

public partial class CustomControls_FeaturedCategory : System.Web.UI.UserControl
{
    protected void Page_Load(object sender, EventArgs e)
    {
        try
        {
            Categories featured = Entities.GetFeaturedCategory();

            Bitmap img = new Bitmap(Utils.GetApplicationSetting(Constants.IMAGES_CATEGORIES_PHYSICAL_PATH) + featured.ImagePath);
            if (img.Width > img.Height) imgFeatured.Width = new Unit(200);
            else imgFeatured.Height = new Unit(200);

            imgFeatured.ImageUrl = Utils.GetApplicationSetting(Constants.IMAGES_CATEGORIES_URL_PREFIX).Replace("~", "") + featured.ImagePath;
            linkTitle.Text = featured.Title;
            linkTitle.NavigateUrl = "/Categorie-" + featured.CategoryID + "-" + featured.Title;
            linkImage.NavigateUrl = "/Categorie-" + featured.CategoryID + "-" + featured.Title;
            lblContent.Text = featured.Description;
        }
        catch { pnlFeaturedCategory.Visible = false; }
    }
}
